A continuación se va desarrollar una página web en GitHub Pages, que muestre un tabla y gráficos con el conjunto de datos página web de datos abiertos del Organismo de Investigación Juficial (OIJ)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
## Linking to GEOS 3.9.1, GDAL 3.3.2, PROJ 7.2.1; sf_use_s2() is TRUE
## Loading required package: sp
## Please note that rgdal will be retired by the end of 2023,
## plan transition to sf/stars/terra functions using GDAL and PROJ
## at your earliest convenience.
##
## rgdal: version: 1.5-32, (SVN revision 1176)
## Geospatial Data Abstraction Library extensions to R successfully loaded
## Loaded GDAL runtime: GDAL 3.4.3, released 2022/04/22
## Path to GDAL shared files: C:/Users/HP/AppData/Local/R/win-library/4.2/rgdal/gdal
## GDAL binary built with GEOS: TRUE
## Loaded PROJ runtime: Rel. 7.2.1, January 1st, 2021, [PJ_VERSION: 721]
## Path to PROJ shared files: C:/Users/HP/AppData/Local/R/win-library/4.2/rgdal/proj
## PROJ CDN enabled: FALSE
## Linking to sp version:1.5-0
## To mute warnings of possible GDAL/OSR exportToProj4() degradation,
## use options("rgdal_show_exportToProj4_warnings"="none") before loading sp or rgdal.
##
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
## Warning in instance$preRenderHook(instance): It seems your data is too big
## for client-side DataTables. You may consider server-side processing: https://
## rstudio.github.io/DT/server.html
grafico_por_tipo_de_delito <-
estadisticas_policiales %>%
count(Delito) %>%
ggplot(aes(x = reorder(Delito, n), y = n)) +
geom_bar(stat = "identity") +
ggtitle("Delitos por tipo ") +
xlab("Tipo de delito") +
ylab("Cantidad") +
coord_flip() +
theme_minimal()
ggplotly(grafico_por_tipo_de_delito)
Estadisticas <-
estadisticas_policiales %>%
mutate(fecha = lubridate::month(Fecha))
mes <-c("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre")
Delitos_por_mes <-
Estadisticas%>%
count(fecha) %>%
ggplot(level =level_order,(aes(x = reorder(mes, fecha), y = n))) +
geom_bar(stat = "identity") +
ggtitle("Delitos durante el año 2021") +
xlab("Mes") +
ylab("Cantidad de delitos") +
theme_minimal()
ggplotly(Delitos_por_mes)
delitos_por_genero <-
estadisticas_policiales %>%
ggplot(aes(x = Delito, fill = Genero)) +
geom_bar(position = "fill") +
ggtitle("Delito por género") +
xlab("Delito") +
ylab("Cantidad") +
labs(fill = "Género") +
coord_flip() +
theme_minimal()+
scale_fill_manual(values = c("#0F0F0F", "#4209ED", "#FF0A6CB3"))
ggplotly(delitos_por_genero) %>% config(locale = 'es')
Delitos_por_cantones <-
estadisticas_policiales %>%
count(Canton) %>%
filter(Canton == "SAN JOSE" |
Canton == "ALAJUELA" |
Canton == "CARTAGO" | Canton == "HEREDIA") %>%
ggplot(aes(x = reorder(Canton, n), y = n)) +
geom_bar(stat = "identity") +
ggtitle("Delitos en los Cantones de San José, Alajuela, Cartago y Heredia") +
xlab("Cantón") +
ylab("Cantidad") +
coord_flip() +
theme_minimal()
ggplotly(Delitos_por_cantones)